package com.example.threadpool.threadpoolconfig;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName Config
 * @Description
 * @Author huyingliang
 * @Date 2024-02-04 15:47
 */
@Configuration
public class Config {

    /*初始化一个线程池，随项目启动而启动*/
    @Bean
    public ThreadPoolExecutor threadPoolInstance() {
        /*自定义线程池*/
        return new ThreadPoolExecutor(5, 10, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10));
    }

}
